<?php

session_start();
include ("../config/koneksi.php");

$username = $_POST['admin_user'];
$pass = $_POST['password'];

if (!empty($username)){
    if (!empty($pass)){
        $sql = mysql_query("SELECT * FROM admin WHERE admin_user='".$username."' AND password='".$pass."'");
        $tes = mysql_num_rows($sql);
            if ($tes == 1){
                $hasil = mysql_fetch_array($sql);
                $_SESSION['admin_user'] = $hasil[0];
                $_SESSION['password'] = $hasil[1];
                header("location:./index.php");
            }else{
                echo "<script type='text/javascript'>
                        alert ('Kombinasi username dan password tidak cocok');
                    </script>
                    <meta http-equiv='refresh' content='0.5;url=http://localhost/jadi/admin/admin.php'>                  
                    ";

            }
    }else{
        echo "Anda belum mengisi password";
    }
}else{
    echo "Anda belum mengisi username";
}
//
?>